package com.bruce.pattern.creational.singleton;

import lombok.Getter;
import lombok.Setter;

/**
 * <pre>
 *  枚举实现单例,代码风格看着有点怪,但是是天然的实现单例
 * </pre>
 * Created by bruce on 2018/11/3 12:11
 */
public enum EnumInstance {
    //enum 类是本质上是 final
    //枚举的构造方法是 private 带有两个参数(String,int) 参数1是枚举值,参数2是ordinal,枚举序号

    //本质上是一个 static final 常量值
    //在 static{ } 块中被实例化
    INSTANCE;

    @Setter
    @Getter
    private Object data;

    public static EnumInstance getInstance() {
        return INSTANCE;
    }


}
